
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/10/17 0017
  Time: 上午 10:42
  To change this template use File | Settings | File Templates.
--%>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>车辆维修--编辑页</title>
    <link rel="stylesheet" href="/static/plugins/layui/css/layui.css">
    <style>
        .part {
            margin-top: 2%;
            width: 95%;
            height: 46%;
        }
        .btnBox {
            padding: 5% 0;
            margin-left: 25%;
        }
        .layui-form-label {
            width: 100px;
        }
        .layui-form-checkbox span{
            height: 30%;
        }

        .layui-input {
            width: 95%;
            margin-left: 23px;
        }
        .layui-textarea{
            width: 95%;
            margin-left: 23px;
        }
    </style>
</head>
<body>
<div class="wrap_padding35">
    <form class="layui-form" action="javascript:">

        <div class="part part1">
            <div class="layui-form-item">
                <label class="layui-form-label">车牌号码：</label>
                <div class="layui-input-block">
                    <input type="hidden" name="recordId" value="${carRepair.recordId}">
                    <input type="text" name="carCode" lay-verify="required" autocomplete="off" class="layui-input" value="${carRepair.carCode}">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">发车里程：</label>
                <div class="layui-input-block">
                    <input type="text" name="initMile" lay-verify="required" autocomplete="off" class="layui-input" value="${carRepair.initMile}">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">发车油量：</label>
                <div class="layui-input-block">
                    <input type="text" name="initOil" lay-verify="required" autocomplete="off" class="layui-input" value="${carRepair.initOil}">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">维修地点：</label>
                <div class="layui-input-block">
                    <input type="text" name="repairAddress" lay-verify="required" autocomplete="off" class="layui-input" value="${carRepair.repairAddress}">
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">出车时间：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="usecarTime" class="layui-input" id="begin" value="<fmt:formatDate value="${carRepair.usecarTime}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate>">
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">经办人员：</label>
                <div class="layui-input-block">
                    <input type="text" name="headMan" lay-verify="required" autocomplete="off" class="layui-input" value="${carRepair.headMan}">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">经办手机：</label>
                <div class="layui-input-block">
                    <input type="text" name="headMobile" lay-verify="required" autocomplete="off" class="layui-input" value="${carRepair.headMobile}">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">维修完毕：</label>
                <div class="layui-input-block">
                    <input type="checkbox" name="check" title="该车辆已经维修完毕，继续填写还车信息" lay-skin="primary" checked>
                </div>
            </div>

        </div>

        <div class="part part2">

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">还车时间：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="returnTime" class="layui-input" id="end" value="<fmt:formatDate value="${carRepair.returnTime}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate>">
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">还车里程：</label>
                <div class="layui-input-block">
                    <input type="text" name="returnMile" autocomplete="off" class="layui-input" value="${carRepair.returnMile}">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">还车油量：</label>
                <div class="layui-input-block">
                    <input type="text" name="returnOil" autocomplete="off" class="layui-input" value="${carRepair.returnOil}">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">维修费用：</label>
                <div class="layui-input-block">
                    <input type="text" name="repairMoney" autocomplete="off" class="layui-input" value="${carRepair.repairMoney}">
                </div>
            </div>

            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">维修内容：</label>
                <div class="layui-input-block">
                    <textarea class="layui-textarea" name="repairContent">${carRepair.repairContent}</textarea>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">备注信息：</label>
                <div class="layui-input-block">
                    <input type="text" name="remark" autocomplete="off" class="layui-input" value="${carRepair.remark}">
                </div>
            </div>

        </div>

        <div class="layui-form-item ">
            <div class="layui-input-block btnBox">
                <button class="layui-btn" lay-submit lay-filter="repair">立即提交</button>
                <button type="button" class="layui-btn layui-btn-primary"><a href="/repair" target="_parent">取消</a></button>
            </div>
        </div>
    </form>
</div>

<script src="/static/plugins/jquery.js"></script>
<script src="/static/plugins/layui/layui.js"></script>

<%--2、引入bootstrap组件--%>
<script src="/static/plugins/bootstrap/js/bootstrap.js"></script>
<%--3、bootstrap table组件以及中文包的引用--%>
<script src="/static/plugins/bootstrap-table/bootstrap-table.js"></script>
<script src="/static/plugins/bootstrap-table/bootstrap-table-zh-CN.js"></script>
<script>
    layui.use(["layer","form","element","laydate"],function () {
        var form = layui.form;
        var laydate = layui.laydate;
        var layer = layui.layer;

        laydate.render({
            elem: '#begin'
            ,type:"datetime"
        });

        laydate.render({
            elem:"#end"
            ,type:"datetime"
        });

        laydate.render({
            elem:"#next"
            ,type:"datetime"
        });

        form.on('checkbox', function(data){
            var checked = data.elem.checked;
            if(checked) {
                $(".part2").show()
            } else {
                $(".part2").hide()
            }

        });

        form.on('submit(repair)', function(data){
            $.ajax({
                url:"/repair/update",
                type:"post",
                data:data.field,
                dataType:"json",
                success:function (msg) {
                    if(msg.code == 1){
                        layer.msg(msg.message,{time:1000,icon:1},function () {
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            parent.$("#tb_car_repair").bootstrapTable("refresh"); // 刷新表格数据
                            parent.layer.close(index); //再执行关闭
                        })
                    } else {
                        layer.msg(msg.message,{time:3000,icon:2});
                    }
                },
                error:function () {
                    console.log("异步方法错误！")
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    })
</script>
</body>
</html>
